/**
 * Copies all the properties from the second passed object to the first passed Object.
 * If you do myWhatever.extend = $extend the first parameter will become myWhatever, and your extend function will only need one parameter.
 * @function $extend
 * @static
 * @return {Object} The first object, extended.
 */
$extend = Object.extend = function(){
	var args = arguments;
	if (!args[1]) args = [this, args[0]];
	for (var property in args[1]) args[0][property] = args[1][property];
	return args[0];
};

/**
 * Abstract class, to be used as singleton. Will add .extend to any object
 * @class Abstract
 * @param {Object} an object
 * @return {Object} the object with an .extend property, equivalent to <$extend>.
 */
var Abstract = function(obj){
	obj = obj || {};
	obj.extend = $extend;
	return obj;
};

/**
 * The base class object of the framework.
 * Creates a new class, its initialize method will fire upon class instantiation.
 * Initialize wont fire on instantiation when you pass *null*.
 * @class _jsc.class
 */

var Class = function(properties) {
	var klass = function() {
		return (arguments[0] !== null && this.init && typeof(this.init) == "function") ? this.init.apply(this, arguments) : this;
	};
	$extend(klass, this);
	klass.prototype = properties;
	klass.constructor = Class;
	return klass;
};